package com.reflect;

import java.lang.reflect.Method;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86184
 * Date: 2023-12-12
 * Time: 11:32
 */
public class Test3 {
    public static void main(String[] args) throws NoSuchMethodException {
        //创建Class对象的类
        Class c = Student.class;
        //public方法名 -->包含继承过来的
        Method[] methods = c.getMethods();
        for (Method method : methods) {
            System.out.println(method.getName());
        }
        System.out.println("---------------------------------------");

        //所有的方法 --->不包含继承的
        Method[] methods1 = c.getDeclaredMethods();
        for (Method method : methods1) {
            System.out.println(method.getName());
        }

        //获取一个方法的修饰符创建对象
        Method sleep = c.getDeclaredMethod("Sleep");
        System.out.println(sleep.getModifiers());


    }
}
